package yao.util.personal.ddl;

public class Field {
	
	public enum FType {
		INTEGER("int|tinyint|smallint|mediumint",  "Integer"),
		STRING("varchar|char|text", "String"),
		DOUBLE("double", "Double"),
		LONG("integer|bigint", "Long"),
		BOOLEAN("bit", "Boolean"),
		FLOAT("float", "Float"),
		BIGDECIMAL("decimal|numeric", "BigDecimal"),
		DATE("date|time|datetime|timestamp|year","Date");
	
		
		private final String ddlKey;
		private final String javaType;
		
		private FType(String ddlKey, String javaType) {
			this.ddlKey = ddlKey;
			this.javaType = javaType;
		}
		public String getDdlKey() {
			return ddlKey;
		}
		
		
		public String getJavaType() {
			return javaType;
		}
		public static FType getType(String ddl) {
			FType[] values = FType.values();
			for(FType type : values) {
				if(type.getDdlKey().contains(ddl)) {
					return type;
				}
			}
			return null;
		}
		
		
	}
		
	private String name;
	private String ddlName;
	private FType type;
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public FType getType() {
		return type;
	}
	public void setType(FType type) {
		this.type = type;
	}
	public String getDdlName() {
		return ddlName;
	}
	public void setDdlName(String ddlName) {
		this.ddlName = ddlName;
	}
	
	
	

}
